package com.miguo.framework.authorize;


import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Digest {
		
	private static MessageDigest getDigest(final String algorithm) {
        try {
            return MessageDigest.getInstance(algorithm);
        } catch (final NoSuchAlgorithmException e) {
            throw new IllegalArgumentException(e);
        }
    }

	private static MessageDigest getMd5Digest() {
        return getDigest(Config.sign_type);
    }

    public static byte[] md5(final byte[] data) {
        return getMd5Digest().digest(data);
    }

    public static String md5Hex(final byte[] data) {
        return Hex.encodeHexString(md5(data));
    }

}

